package com.kawa.controller;

import com.kawa.entity.po.User;
import com.kawa.model.R;
import com.kawa.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserInfoController {

    @Autowired
    private UserInfoService userInfoService;

    @GetMapping("/users/current/info")
    public R<User> getUserInfo(@RequestHeader("Authorization") String token) {
       User userInfo = userInfoService.getUserInfo(token);

        return userInfo != null ? R.ok(userInfo,"success"):R.fail("fail");

    }


}
